using System;
using System.Collections.Generic;

using MVPComposibility.ContactManager.DomainModel;
using MVPComposibility.ContactManager.Views.ContactManager;
using WCSFContrib.Extensions.EventBroker;
using WCSFContrib.Extensions.Utility;

namespace MVPComposibility.ContactManager.Views.ContactList
{
	public interface IContactListModel
	{
		event EventHandler SelectedContactChanged;
		event EventHandler ContentChanged;
		event EventHandler Initialized;

		IEnumerable<Contact> GetAllContacts();
		Contact SelectedContact { get; }
		int SelectedContactIndex { get; set; }

		/// <summary>
		/// Called when the model is reloaded after a postback. This restores
		/// the currently selected model index, but does not fire the
		/// SelectedContactChanged event.
		/// </summary>
		/// <param name="selectedContactIndex">The index of the currently selected contact.</param>
		void RestoreSelectedContactFromPersistentState(int selectedContactIndex);

		/// <summary>
		/// Fires ContentChanged event.
		/// </summary>
		void ContentChange();

		[EventPublication(ContactManagerTopics.SelectedContactChanged)]
		event EventHandler<DataEventArgs<Contact>> SelectedContactChangedGeneric;

		[EventPublication(ContactManagerTopics.Initialized)]
		event EventHandler<DataEventArgs<Contact>> InitializedGeneric;

		[EventSubscription(ContactManagerTopics.ContactNameChanged)]
		void ContactNameChanged();
	}
}